package day6;

import java.util.Scanner;

public class Travl {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while (true){
            System.out.print("请输入姓名：");
            String str=sc.next();
            if ("n".equals(str)) break;
            System.out.print("请输入年龄：");
            int i= sc.nextInt();
            Travl t=new Travl();
            t.people(str,i);
        }

    }
    public void people(String name, int age){
        int price=0;
        if (age<18){
            price=0;
            System.out.println(name+"的年龄为："+age+",门票价格为："+price);
        }else {
            price=20;
            System.out.println(name+"的年龄为："+age+",门票价格为："+price);
        }
        System.out.println();

    }
}

 class Visitors {
    public String name;
    public int age;
    public void print(){
        if(age>18){
            System.out.println(name+"年龄:"+
                    age+",门票价格:20元");
        }else{
            System.out.println(name+"年龄:"+
                    age+",门票免费");
        }
    }
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(true) {
            System.out.print("请输入姓名:");
            String name = sc.next();
            if("n".equals(name)) break;
            System.out.print("请输入年龄:");
            int age = sc.nextInt();
            //1.创建对象
            Visitors v = new Visitors();
            //2.对象.属性名
            v.name = name;
            v.age = age;
            //3.对象.方法名
            v.print();
        }
        System.out.println("退出程序");
    }
}